package demo.service;

import java.sql.ResultSet;
import java.sql.SQLException;

import demo.dao.MemberDAO;

public class ServiceMember
{
	public static boolean addMember(String inName, String inAddress, String inJob)
	{
		MemberDAO memberdao = new MemberDAO();
		ResultSet rs = memberdao.queryIdByName(inName);
		try
		{
			rs.last();
			if (rs.getRow() != 0)
			{
				System.out.println("Error. " + inName + "已存在");
				return false;
			} else
			{
				memberdao.setName(inName);
				memberdao.setAddress(inAddress);
				memberdao.setJob(inJob);
				memberdao.save();
				System.out.println("OK. " + inName + "'member id is "
						+ memberdao.getMaxId());
				return true;
			}
		} catch (SQLException e)
		{
			e.printStackTrace();
		}
		return false;
	}
}
